package cn.net.wangyixinwen.test;

import cn.net.wangyixinwen.api.ApiService;
import cn.net.wangyixinwen.bean.OrderBean;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

//https://mobile.ximalaya.com/mobile/discovery/v2/categories?channel=and-d8&code=43_310000_3100&device=android&picVersion=11&scale=2&version=5.4.45
public class OrderRepository {
    private static final String URL = "https://mobile.ximalaya.com/" ;
    private ApiService service ;
    public OrderRepository(){
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(URL)
                .addCallAdapterFactory(RxJava3CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build() ;
        service = retrofit.create(ApiService.class) ;
    }

    public Observable<OrderBean> getData(){
        return service.getCategories("and-d8","43_310000_3100","android",11,2,"5.4.45")
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
}
